1. Field of the Invention
The present invention relates generally to texture mapping in graphics systems, and more particularly to a system and method of selecting a level of detail for texture mapping operations.
2. Description of Background Art
Texture mapping is a well known technique in computer-implemented graphics systems. In general, texture mapping involves mapping a two-dimensional image ("texture") onto a selected region in a frame buffer or other two-dimensional space. The selected region may represent, for example, a projection of a surface in three-dimensional space. In such a situation, texture mapping is often used to convey the impression that the surface is a component of a solid object in three-dimensional space, having surface characteristics corresponding to the defined texture.
In principle, the concept of texture mapping operates as follows. The surface to be rendered contains a number of individual picture elements ("pixels"), that may be identified by reference to their coordinates (x,y) in two-dimensional screen space. The texture to be mapped onto the surface contains a number of individual texture elements ("texels"), that may be identified by reference to their coordinates (u,v) in two-dimensional texture space. Each texel has certain material values such as color, luminance, and the like, defined by the texture stored in the texture map.
Each pixel in the surface to be rendered is mapped to a particular texel, and the material values associated with that texel are applied to the pixel. In some situations, values may be interpolated and/or filtered among two or more texels for application to a pixel. Since the surface and the texture may be of differing shapes and sizes, the process of applying the texture to the surface often involves scaling and interpolation. In particular, when the surface being rendered is representative of a three-dimensional surface, perspective correction and other distortion techniques are applied in order to provide a realistic appearance.
In many situations, the process of scaling a texture in order to apply it to a surface may be computationally expensive. Typically, such scaling is accomplished by filtering, or averaging, material values for a number of texels in order to derive a material value to be applied to a pixel. Where the scaling factor is significant, such filtering techniques are often too slow for realtime rendering operations.
Accordingly, it is known in the art to provide several versions of a texture map, each associated with a different level of detail (LOD). These versions are usually developed a priori, so that they may be available as needed during rendering operations. During rendering, the system selects the LOD most suitable for rendering a particular pixel, so as to reduce the complexity of scaling operations that need to be performed. Generally, such selection is performed based on the relative area of the surface being rendered, as compared with the size of the texel to be mapped. The smaller the area, corresponding to a smaller total number of pixels in the surface, the lower the level of detail selected.
Once an LOD has been selected, any of a number of techniques may be used for filtering of the texture. These techniques determine a material value to be applied to a pixel at a particular x,y coordinate that corresponds to a u,v position in the texture. For example, any of the following four techniques, among others, are in general use, depending on the application and the limitations of the particular system:
Point sampling (the nearest LOD is selected, and the material value for the nearest texel to position u,v is used) PA1 Linear filtering (the nearest two LODs are selected; material values for the nearest texel to position u,v in each LOD are determined; a weighted average between the two material values, weighted by the relative proximity to each LOD, is used) PA1 Bilinear filtering (the nearest LOD is selected, and the material values for the four nearest texels to position u,v are subject to weighted averaging based on the exact value of u,v; the weighted average is used) PA1 Trilinear filtering (the above-described bilinear filtering technique is applied to the nearest two LODs; a weighted average between the two results, weighted by the relative proximity to each LOD, is used)
Whichever of the above techniques is used, the system must first select an appropriate LOD to be used for each pixel to be rendered. One known technique for LOD selection is to measure the distance in texture space coordinates (u,v) that corresponds to a unit distance in screen space coordinates (x,y). A large change in texture space coordinates indicates that the texture can be traversed in fewer unit steps, and therefore a smaller LOD should be used. Conversely, a small change in texture space coordinates indicates that a larger LOD should be used.
The distance in texture space coordinates corresponding to a unit distance in screen space is expressed as (.DELTA.u,.DELTA.v). Graphics systems generally select LOD for a given pixel (x,y) by taking the base-two logarithm of the largest measured value of .DELTA.u or .DELTA.v surrounding point (x,y). Ideally, all .DELTA.u and .DELTA.v values for a unit circle (in screen space) around point (x,y) would be measured and the largest value taken. However, due to the impracticality of computing .DELTA.u and .DELTA.v for all points around a unit circle, most graphics systems sample discrete points. Typically, a pixel directly above and/or below the point (i.e. (x,y-1) and/or (x,y+1)), and a pixel directly horizontally adjacent to the point (i.e. (x-1,y) and/or (x+1,y)) are used. Some systems also use the pixels diagonally adjacent to the point (i.e. (x-1,y-1), (x-1,y+1), (x+1,y-1), and/or (x+1,y+1)) and scale down to take into account that such pixels do not lie on the unit circle.
All of the above techniques introduce computational complexity due to the fact that each measurement of .DELTA.u and .DELTA.v requires a significant amount of calculation. Typically, in order to determine u and v values for a given pixel, two additions, two multiplications, and one division are required. On the other hand, a sufficient number of such comparisons are required in order to facilitate satisfactory LOD selection. Thus, in many systems, LOD selection is compromised by the fact that an insufficient number of .DELTA.u and .DELTA.v values are available. Conversely, some systems are able to perform the additional computations for more accurate LOD selection, but such systems generally require relatively powerful processors.
What is needed is a system and method of determining a sufficient number of .DELTA.u and .DELTA.v values surrounding a given pixel to provide effective selection of LOD, without introducing undue computational expense.